//
//  MainViewController.swift
//  sina
//
//  Created by wan on 15/12/23.
//  Copyright © 2015年 wan. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        //添加子视图控制器
        addChildViewControllers()
    }
    
    private func addChildViewControllers() {
        addChildViewController(HomeTableViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(MessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(DiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(ProfileTableViewController(), title: "我", imageName: "tabbar_profile")


    }
    private func addChildViewController(vc:UIViewController,title:String,imageName:String) {
//        let homeVC = HomeTableViewController()
        self.tabBar.tintColor = UIColor.orangeColor()
        let nav = UINavigationController(rootViewController: vc)
        //        nav.title = "首页"
        vc.title = title
        //设置图片
        vc.tabBarItem.image = UIImage(named: imageName)

        addChildViewController(nav)
    }
    
}
